package com.weijun.keepalive.activity

import android.app.Activity
import android.os.Bundle
import android.view.Gravity
import com.weijun.keepalive.isScreenOn
import com.weijun.keepalive.logE

/**
 * @author: weijun
 * date: 2023/7/5
 * description: 一像素的 Activity
 */
class OnePixelActivity : Activity() {

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        "OnePixelActivity onCreate".logE()
        //设定一像素的activity
        window.setGravity(Gravity.START or Gravity.TOP)
        window.attributes = window.attributes.apply {
            x = 0
            y = 0
            height = 1
            width = 1
        }
    }

    override fun onResume() {
        super.onResume()
        "OnePixelActivity onResume:${isScreenOn()}".logE()
        if (isScreenOn()) {
            finish()
        }
    }

}